package chapter5;
import static utility.Print.*;

/* 
 * The static initializers for Cups run when either the access of the static object cup1 occurs
 * on the line marked (1), or if line (1) is commented out and the lines marked (2) are
 * uncommented. If both (1) and (2) are commented out, the static initialization for Cups
 * never occurs, as you can see from the output. Also, it doesn’t matter if one or both of the lines 
 * marked (2) are uncommented; the static initialization only occurs once.
 * Exercise 13: (1) Verify the statements in the previous paragraph.
 */
class Cup {
	Cup(int marker) {
		print("Cup(" + marker + ")");
	}
	void f(int marker) {
	print("f(" + marker + ")");
	}
}
class Cups {
	static Cup cup1 = new Cup(3);
	static Cup cup2 = new Cup(4);
	static {
		cup1 = new Cup(1);
		cup2 = new Cup(2);
	}
	Cups() {
		print("Cups()");
	}
}

public class Exercise13 {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Cups.cup1.f(99);
		Cups.cup1.f(99);
	}

}
